home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / dropde-2.zip / CLIENT.QC < prev    next >
Text File  |  1996-09-27  |  40KB  |  1,745 lines

  1. // prototypes
  2. void() W_WeaponFrame;
  3. void() W_SetCurrentAmmo;
  4. void() player_pain;
  5. void() player_stand1;
  6. void (vector org) spawn_tfog;
  7. void (vector org, entity death_owner) spawn_tdeath;
  8.  
  9. float    modelindex_eyes, modelindex_player;
  10.  
  11. // DD code
  12. entity connect_player;
  13. void() HookVanish;
  14.  
  15. /*
  16. =============================================================================
  17.  
  18.                 LEVEL CHANGING / INTERMISSION
  19.  
  20. =============================================================================
  21. */
  22.  
  23. float    intermission_running;
  24. float    intermission_exittime;
  25. float button_pressed;
  26. float winner;
  27.  
  28.  
  29. void() SetWinner =
  30. {
  31.     if (teamplay <= 0)
  32.         return;
  33.  
  34.     local float team_flag;
  35.     local float team1;
  36.     local float team2;
  37.     local float team3;
  38.     local float team4;
  39.  
  40.     // Get frag count for each team.
  41.     team_flag = 0;
  42.     team1 = team2 = team3 = team4 = 0;
  43.     other = find (world, classname, "player");
  44.     while (other != world)
  45.     {
  46.         if (other.start_team == actual_team1)
  47.         {
  48.             team_flag = team_flag | 1;
  49.             team1 = team1 + other.frags;
  50.         }
  51.         else if (other.start_team == actual_team2)
  52.         {
  53.             team_flag = team_flag | 2;
  54.             team2 = team2 + other.frags;
  55.         }
  56.         else if (other.start_team == actual_team3)
  57.         {
  58.             team_flag = team_flag | 4;
  59.             team3 = team3 + other.frags;
  60.         }
  61.         else if (other.start_team == actual_team4)
  62.         {
  63.             team_flag = team_flag | 8;
  64.             team4 = team4 + other.frags;
  65.         }
  66.         other = find (other, classname, "player");
  67.     }
  68.  
  69.     // Check if only one team is playing.
  70.     if (team_flag <= 2 || team_flag == 4 || team_flag == 8)
  71.     {
  72.         winner = -1;  // Only 1 team - No winner and no score.
  73.         return;
  74.     }
  75.  
  76.     winner = 0;
  77.     if (team1 > team2)
  78.     {
  79.         if (team1 > team3)
  80.         {
  81.             if (team1 > team4)
  82.                 winner = actual_team1;
  83.             else
  84.                 winner = actual_team4;
  85.         }
  86.         else if (team3 > team4)
  87.             winner = actual_team3;
  88.         else
  89.             winner = actual_team4;
  90.     }
  91.     else if (team2 > team3)
  92.     {
  93.         if (team2 > team4)
  94.             winner = actual_team2;
  95.         else
  96.             winner = actual_team4;
  97.     }
  98.     else if (team3 > team4)
  99.         winner = actual_team3;
  100.     else
  101.         winner = actual_team4;
  102. };
  103.  
  104.  
  105. void() PrintWinner =
  106. {
  107.     if (winner == 0)
  108.         bprint("No team won the last level due to a tie.\n");
  109.     else if (winner > 0)
  110.     {
  111.         ConfigTeam(0, winner);
  112.         sprint(self.owner, "The ");
  113.         sprint(self.owner, team_name);
  114.         sprint(self.owner, " team (");
  115.         sprint(self.owner, skin_name);
  116.         sprint(self.owner, " Skin) won the last level!\n");
  117.     }
  118.     winner = -1;
  119.     remove(self);
  120. };
  121.  
  122.  
  123. /*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16)
  124. This is the camera point for the intermission.
  125. Use mangle instead of angle, so you can set pitch or roll as well as yaw.  'pitch roll yaw'
  126. */
  127. void() info_intermission =
  128. {
  129. };
  130.  
  131.  
  132. void() ResetParms =
  133. {
  134.     parm1 = IT_SHOTGUN | IT_AXE | IT_MORNINGSTAR;
  135.     parm2 = 100;
  136.     parm3 = 0;
  137.     parm4 = 25;
  138.     parm5 = 0;
  139.     parm6 = 0.8;  // For DD.
  140.     parm7 = 0;
  141.     parm8 = 1;
  142.     parm9 = 0;
  143.     // DD code
  144.     parm10 = self.skin;
  145.     parm11 = self.start_team;
  146.     parm12 = winner;
  147. };
  148.  
  149. void() SetChangeParms =
  150. {
  151.     if (self.health < 1)  // DD
  152.     {
  153.         ResetParms();
  154.         return;
  155.     }
  156. // remove items
  157.     self.items = self.items - (self.items & 
  158.     (IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD) );
  159.     
  160. // cap super health
  161.     if (self.health > 100)
  162.         self.health = 100;
  163.     if (self.health < 50)
  164.         self.health = 50;
  165.     parm1 = self.items;
  166.     parm2 = self.health;
  167.     parm3 = self.armorvalue;
  168.     if (self.ammo_shells < 25)
  169.         parm4 = 25;
  170.     else
  171.         parm4 = self.ammo_shells;
  172.     parm5 = self.ammo_nails;
  173.     parm6 = self.ammo_rockets;
  174.     parm7 = self.ammo_cells;
  175.     parm8 = self.weapon;
  176.     parm9 = self.armortype * 100;
  177.     // DD code
  178.     parm10 = self.skin;
  179.     parm11 = self.start_team;
  180.     parm12 = winner;
  181. };
  182.  
  183. void() SetNewParms =
  184. {
  185.     parm1 = IT_SHOTGUN | IT_AXE | IT_MORNINGSTAR;
  186.     parm2 = 100;
  187.     parm3 = 0;
  188.     parm4 = 25;
  189.     parm5 = 0;
  190.     parm6 = 0.8;  // For DD
  191.     parm7 = 0;
  192.     parm8 = 1;
  193.     parm9 = 0;
  194.     // DD code
  195.     parm10 = 0;
  196.     parm11 = 0;
  197.     parm12 = -1;
  198. };
  199.  
  200. void() DecodeLevelParms =
  201. {
  202.     if (serverflags)
  203.     {
  204.         if (world.model == "maps/start.bsp")
  205.             ResetParms ();        // take away all stuff on starting new episode
  206.     }
  207.     
  208.     self.items = parm1;
  209.     self.health = parm2;
  210.     self.armorvalue = parm3;
  211.     self.ammo_shells = parm4;
  212.     self.ammo_nails = parm5;
  213.     self.ammo_rockets = parm6;
  214.     self.ammo_cells = parm7;
  215.     self.weapon = parm8;
  216.     self.armortype = parm9 * 0.01;
  217.     self.skin = parm10;
  218.     self.start_team = parm11;
  219.     winner = parm12;
  220. };
  221.  
  222. /*
  223. ============
  224. FindIntermission
  225.  
  226. Returns the entity to view from
  227. ============
  228. */
  229. entity() FindIntermission =
  230. {
  231.     local    entity spot;
  232.     local    float cyc;
  233.  
  234. // look for info_intermission first
  235.     spot = find (world, classname, "info_intermission");
  236.     if (spot)
  237.     {    // pick a random one
  238.         cyc = random() * 4;
  239.         while (cyc > 1)
  240.         {
  241.             spot = find (spot, classname, "info_intermission");
  242.             if (!spot)
  243.                 spot = find (spot, classname, "info_intermission");
  244.             cyc = cyc - 1;
  245.         }
  246.         return spot;
  247.     }
  248.  
  249. // then look for the start position
  250.     spot = find (world, classname, "info_player_start");
  251.     if (spot)
  252.         return spot;
  253.     
  254. // testinfo_player_start is only found in regioned levels
  255.     spot = find (world, classname, "testplayerstart");
  256.     if (spot)
  257.         return spot;
  258.     
  259.     objerror ("FindIntermission: no spot");
  260. };
  261.  
  262.  
  263. string nextmap;
  264. void() GotoNextMap =
  265. {
  266.     if (cvar("samelevel"))    // if samelevel is set, stay on same level
  267.         changelevel (mapname);
  268.     else
  269.         changelevel (nextmap);
  270. };
  271.  
  272.  
  273. void() ExitIntermission =
  274. {
  275. // skip any text in deathmatch
  276.     if (deathmatch)
  277.     {
  278.         GotoNextMap ();
  279.         return;
  280.     }
  281.     
  282.     intermission_exittime = time + 1;
  283.     intermission_running = intermission_running + 1;
  284.  
  285. //
  286. // run some text if at the end of an episode
  287. //
  288.     if (intermission_running == 2)
  289.     {
  290.         if (world.model == "maps/e1m7.bsp")
  291.         {
  292.             WriteByte (MSG_ALL, SVC_CDTRACK);
  293.             WriteByte (MSG_ALL, 2);
  294.             WriteByte (MSG_ALL, 3);
  295.             if (!cvar("registered"))
  296.             {
  297.                 WriteByte (MSG_ALL, SVC_FINALE);
  298.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task in the other three\nhaunted lands of Quake. Or are you? If\nyou don't register Quake, you'll never\nknow what awaits you in the Realm of\nBlack Magic, the Netherworld, and the\nElder World!");
  299.             }
  300.             else
  301.             {
  302.                 WriteByte (MSG_ALL, SVC_FINALE);
  303.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task. A Rune of magic\npower lies at the end of each haunted\nland of Quake. Go forth, seek the\ntotality of the four Runes!");
  304.             }
  305.             return;
  306.         }
  307.         else if (world.model == "maps/e2m6.bsp")
  308.         {
  309.             WriteByte (MSG_ALL, SVC_CDTRACK);
  310.             WriteByte (MSG_ALL, 2);
  311.             WriteByte (MSG_ALL, 3);
  312.  
  313.             WriteByte (MSG_ALL, SVC_FINALE);
  314.             WriteString (MSG_ALL, "The Rune of Black Magic throbs evilly in\nyour hand and whispers dark thoughts\ninto your brain. You learn the inmost\nlore of the Hell-Mother; Shub-Niggurath!\nYou now know that she is behind all the\nterrible plotting which has led to so\nmuch death and horror. But she is not\ninviolate! Armed with this Rune, you\nrealize that once all four Runes are\ncombined, the gate to Shub-Niggurath's\nPit will open, and you can face the\nWitch-Goddess herself in her frightful\notherworld cathedral.");
  315.             return;
  316.         }
  317.         else if (world.model == "maps/e3m6.bsp")
  318.         {
  319.             WriteByte (MSG_ALL, SVC_CDTRACK);
  320.             WriteByte (MSG_ALL, 2);
  321.             WriteByte (MSG_ALL, 3);
  322.  
  323.             WriteByte (MSG_ALL, SVC_FINALE);
  324.             WriteString (MSG_ALL, "The charred viscera of diabolic horrors\nbubble viscously as you seize the Rune\nof Hell Magic. Its heat scorches your\nhand, and its terrible secrets blight\nyour mind. Gathering the shreds of your\ncourage, you shake the devil's shackles\nfrom your soul, and become ever more\nhard and determined to destroy the\nhideous creatures whose mere existence\nthreatens the souls and psyches of all\nthe population of Earth.");
  325.             return;
  326.         }
  327.         else if (world.model == "maps/e4m7.bsp")
  328.         {
  329.             WriteByte (MSG_ALL, SVC_CDTRACK);
  330.             WriteByte (MSG_ALL, 2);
  331.             WriteByte (MSG_ALL, 3);
  332.  
  333.             WriteByte (MSG_ALL, SVC_FINALE);
  334.             WriteString (MSG_ALL, "Despite the awful might of the Elder\nWorld, you have achieved the Rune of\nElder Magic, capstone of all types of\narcane wisdom. Beyond good and evil,\nbeyond life and death, the Rune\npulsates, heavy with import. Patient and\npotent, the Elder Being Shub-Niggurath\nweaves her dire plans to clear off all\nlife from the Earth, and bring her own\nfoul offspring to our world! For all the\ndwellers in these nightmare dimensions\nare her descendants! Once all Runes of\nmagic power are united, the energy\nbehind them will blast open the Gateway\nto Shub-Niggurath, and you can travel\nthere to foil the Hell-Mother's plots\nin person.");
  335.             return;
  336.         }
  337.  
  338.         GotoNextMap();
  339.     }
  340.     
  341.     if (intermission_running == 3)
  342.     {
  343.         if (!cvar("registered"))
  344.         {    // shareware episode has been completed, go to sell screen
  345.             WriteByte (MSG_ALL, SVC_SELLSCREEN);
  346.             return;
  347.         }
  348.         
  349.         if ( (serverflags&15) == 15)
  350.         {
  351.             WriteByte (MSG_ALL, SVC_FINALE);
  352.             WriteString (MSG_ALL, "Now, you have all four Runes. You sense\ntremendous invisible forces moving to\nunseal ancient barriers. Shub-Niggurath\nhad hoped to use the Runes Herself to\nclear off the Earth, but now instead,\nyou will use them to enter her home and\nconfront her as an avatar of avenging\nEarth-life. If you defeat her, you will\nbe remembered forever as the savior of\nthe planet. If she conquers, it will be\nas if you had never been born.");
  353.             return;
  354.         }
  355.         
  356.     }
  357.  
  358.     GotoNextMap();
  359. };
  360.  
  361. /*
  362. ============
  363. IntermissionThink
  364.  
  365. When the player presses attack or jump, change to the next level
  366. ============
  367. */
  368. void() IntermissionThink =
  369. {
  370.     if (time < intermission_exittime)
  371.         return;
  372.  
  373.     if (time < intermission_exittime + 10)
  374.     {
  375.         if (!button_pressed)
  376.         {
  377.             if (self.button0 || self.button1 || self.button2)
  378.                 button_pressed = 1;
  379.             return;
  380.         }
  381.         else
  382.         {
  383.             if (self.button0 || self.button1 || self.button2)
  384.                 return;
  385.         }
  386.     }
  387.     
  388.     ExitIntermission ();
  389. };
  390.  
  391. void() execute_changelevel =
  392. {
  393.     local entity    pos;
  394.  
  395.     intermission_running = 1;
  396.     
  397. // enforce a wait time before allowing changelevel
  398.     if (deathmatch)
  399.         intermission_exittime = time + 5;
  400.     else
  401.         intermission_exittime = time + 2;
  402.     button_pressed = 0;
  403.  
  404.     WriteByte (MSG_ALL, SVC_CDTRACK);
  405.     WriteByte (MSG_ALL, 3);
  406.     WriteByte (MSG_ALL, 3);
  407.     
  408.     pos = FindIntermission ();
  409.  
  410.     other = find (world, classname, "player");
  411.     while (other != world)
  412.     {
  413.         other.view_ofs = '0 0 0';
  414.         other.angles = other.v_angle = pos.mangle;
  415.         other.fixangle = TRUE;        // turn this way immediately
  416.         other.nextthink = time + 0.5;
  417.         other.takedamage = DAMAGE_NO;
  418.         other.solid = SOLID_NOT;
  419.         other.movetype = MOVETYPE_NONE;
  420.         other.modelindex = 0;
  421.         setorigin (other, pos.origin);
  422.         other = find (other, classname, "player");
  423.     }    
  424.  
  425.     WriteByte (MSG_ALL, SVC_INTERMISSION);
  426. };
  427.  
  428.  
  429. void() changelevel_touch =
  430. {
  431.     // DD code
  432.     if ( teamplay && (deathmatch || coop) )
  433.         connect_player.check_team_time = time + 0.5;
  434.  
  435.     if (other.classname != "player")
  436.         return;
  437.  
  438.     if (cvar("noexit"))
  439.     {
  440.         T_Damage (other, self, self, 50000);
  441.         return;
  442.     }
  443.  
  444.     bprint (other.netname);
  445.     bprint (" exited the level\n");
  446.  
  447.     SetWinner();  // DD
  448.     
  449.     nextmap = self.map;
  450.  
  451.     SUB_UseTargets ();
  452.  
  453.     if ( (self.spawnflags & 1) && (deathmatch == 0) )
  454.     {    // NO_INTERMISSION
  455.         GotoNextMap();
  456.         return;
  457.     }
  458.     
  459.     self.touch = SUB_Null;
  460.  
  461. // we can't move people right now, because touch functions are called
  462. // in the middle of C movement code, so set a think time to do it
  463.     self.think = execute_changelevel;
  464.     self.nextthink = time + 0.1;
  465. };
  466.  
  467. /* QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION
  468. When the player touches this, he gets sent to the map listed in the "map"
  469. variable.  Unless the NO_INTERMISSION flag is set, the view will go to the
  470. info_intermission spot and display stats.
  471. */
  472. void() trigger_changelevel =
  473. {
  474.     if (!self.map)
  475.         objerror ("changelevel trigger doesn't have map");
  476.     
  477.     InitTrigger ();
  478.     self.touch = changelevel_touch;
  479. };
  480.  
  481.  
  482. /*
  483. =============================================================================
  484.  
  485.                 PLAYER GAME EDGE FUNCTIONS
  486.  
  487. =============================================================================
  488. */
  489.  
  490. void() set_suicide_frame;
  491.  
  492. // called by ClientKill and DeadThink
  493. void() respawn =
  494. {
  495.     if (self.hook != world)
  496.     {
  497.         local entity save_self;
  498.         save_self = self;
  499.         self = self.hook;
  500.         HookVanish();
  501.         self = save_self;
  502.     }
  503.  
  504.     if (coop)
  505.     {
  506.         // make a copy of the dead body for appearances sake
  507.         CopyToBodyQue (self);
  508.         // get the spawn parms as they were at level start
  509.         setspawnparms (self);
  510.         // respawn        
  511.         PutClientInServer ();
  512.     }
  513.     else if (deathmatch)
  514.     {
  515.         // make a copy of the dead body for appearances sake
  516.         CopyToBodyQue (self);
  517.         // DD code
  518.         ResetParms ();
  519.         // respawn        
  520.         PutClientInServer ();
  521.     }
  522.     else
  523.     {    // restart the entire server
  524.         localcmd ("restart\n");
  525.     }
  526. };
  527.  
  528.  
  529. /*
  530. ============
  531. ClientKill
  532.  
  533. Player entered the suicide command
  534. ============
  535. */
  536. void() ClientKill =
  537. {
  538.     bprint (self.netname);
  539.     bprint (" suicides\n");
  540.     set_suicide_frame ();
  541.     self.modelindex = modelindex_player;
  542.     self.frags = self.frags - 2;    // extra penalty
  543.     respawn ();
  544. };
  545.  
  546. float(vector v) CheckSpawnPoint =
  547. {
  548.     return FALSE;
  549. };
  550.  
  551. /*
  552. ============
  553. SelectSpawnPoint
  554.  
  555. Returns the entity to spawn at
  556. ============
  557. */
  558. entity() SelectSpawnPoint =
  559. {
  560.     local    entity spot;
  561.     
  562. // testinfo_player_start is only found in regioned levels
  563.     spot = find (world, classname, "testplayerstart");
  564.     if (spot)
  565.         return spot;
  566.         
  567. // choose a info_player_deathmatch point
  568.     if (coop)
  569.     {
  570.         lastspawn = find(lastspawn, classname, "info_player_coop");
  571.         if (lastspawn == world)
  572.             lastspawn = find (lastspawn, classname, "info_player_start");
  573.         if (lastspawn != world)
  574.             return lastspawn;
  575.     }
  576.     else if (deathmatch)
  577.     {
  578.         lastspawn = find(lastspawn, classname, "info_player_deathmatch");
  579.         if (lastspawn == world)
  580.             lastspawn = find (lastspawn, classname, "info_player_deathmatch");
  581.         if (lastspawn != world)
  582.             return lastspawn;
  583.     }
  584.  
  585.     if (serverflags)
  586.     {    // return with a rune to start
  587.         spot = find (world, classname, "info_player_start2");
  588.         if (spot)
  589.             return spot;
  590.     }
  591.     
  592.     spot = find (world, classname, "info_player_start");
  593.     if (!spot)
  594.         error ("PutClientInServer: no info_player_start on level");
  595.     
  596.     return spot;
  597. };
  598.  
  599. /*
  600. ===========
  601. PutClientInServer
  602.  
  603. called each time a player is spawned
  604. ============
  605. */
  606. void() PlayerDie;
  607. // DD function.
  608. void() PlayerTouch;
  609.  
  610.  
  611. void() PutClientInServer =
  612. {
  613.     local    entity spot;
  614.  
  615.     self.classname = "player";
  616.     self.health = 100;
  617.     self.takedamage = DAMAGE_AIM;
  618.     self.solid = SOLID_SLIDEBOX;
  619.     self.movetype = MOVETYPE_WALK;
  620.     self.show_hostile = 0;
  621.     self.max_health = 100;
  622.     self.flags = FL_CLIENT;
  623.     self.air_finished = time + 12;
  624.     self.dmg = 2;           // initial water damage
  625.     self.super_damage_finished = 0;
  626.     self.radsuit_finished = 0;
  627.     self.invisible_finished = 0;
  628.     self.invincible_finished = 0;
  629.     self.effects = 0;
  630.     self.invincible_time = 0;
  631.  
  632.     self.flags = self.flags - (self.flags & FL_ONFIRE);
  633.     self.hook = world;
  634.  
  635.     DecodeLevelParms ();
  636.  
  637.     W_SetCurrentAmmo ();
  638.  
  639.     self.attack_finished = time;
  640.     self.th_pain = player_pain;
  641.     self.th_die = PlayerDie;
  642.  
  643.     // DD code.
  644.     self.touch = PlayerTouch;
  645.  
  646.     self.deadflag = DEAD_NO;
  647. // paustime is set by teleporters to keep the player from moving a while
  648.     self.pausetime = 0;
  649.     
  650.     spot = SelectSpawnPoint ();
  651.  
  652.     self.origin = spot.origin + '0 0 1';
  653.     self.angles = spot.angles;
  654.     self.fixangle = TRUE;        // turn this way immediately
  655.  
  656. // oh, this is a hack!
  657.     setmodel (self, "progs/eyes.mdl");
  658.     modelindex_eyes = self.modelindex;
  659.  
  660.     setmodel (self, "progs/player.mdl");
  661.     modelindex_player = self.modelindex;
  662.  
  663.     setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
  664.     
  665.     self.view_ofs = '0 0 22';
  666.  
  667.     player_stand1 ();
  668.     
  669.     if (deathmatch || coop)
  670.     {
  671.         makevectors(self.angles);
  672.         spawn_tfog (self.origin + v_forward*20);
  673.     }
  674.  
  675.     spawn_tdeath (self.origin, self);
  676.  
  677.     // DD code.
  678.     if (winner >= 0)
  679.     {
  680.         local entity winner_ent;
  681.         winner_ent = spawn();
  682.         winner_ent.owner = self;
  683.         winner_ent.think = PrintWinner;
  684.         winner_ent.nextthink = time + 0.25;
  685.     }
  686. };
  687.  
  688.  
  689. /*
  690. =============================================================================
  691.  
  692.                 QUAKED FUNCTIONS
  693.  
  694. =============================================================================
  695. */
  696.  
  697.  
  698. /*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24)
  699. The normal starting point for a level.
  700. */
  701. void() info_player_start =
  702. {
  703. };
  704.  
  705.  
  706. /*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24)
  707. Only used on start map for the return point from an episode.
  708. */
  709. void() info_player_start2 =
  710. {
  711. };
  712.  
  713.  
  714. /*
  715. saved out by quaked in region mode
  716. */
  717. void() testplayerstart =
  718. {
  719. };
  720.  
  721. /*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24)
  722. potential spawning position for deathmatch games
  723. */
  724. void() info_player_deathmatch =
  725. {
  726. };
  727.  
  728. /*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24)
  729. potential spawning position for coop games
  730. */
  731. void() info_player_coop =
  732. {
  733. };
  734.  
  735. /*
  736. ===============================================================================
  737.  
  738. RULES
  739.  
  740. ===============================================================================
  741. */
  742.  
  743. void(entity c) PrintClientScore =
  744. {
  745.     if (c.frags > -10 && c.frags < 0)
  746.         bprint (" ");
  747.     else if (c.frags >= 0)
  748.     {
  749.         if (c.frags < 100)
  750.             bprint (" ");
  751.         if (c.frags < 10)
  752.             bprint (" ");
  753.     }
  754.     bprint (ftos(c.frags));
  755.     bprint (" ");
  756.     bprint (c.netname);
  757.     bprint ("\n");
  758. };
  759.  
  760. void() DumpScore =
  761. {
  762.     local entity    e, sort, walk;
  763.  
  764.     if (world.chain)
  765.         error ("DumpScore: world.chain is set");
  766.  
  767. // build a sorted lis
  768.     e = find(world, classname, "player");
  769.     sort = world;
  770.     while (e)
  771.     {
  772.         if (!sort)
  773.         {
  774.             sort = e;
  775.             e.chain = world;
  776.         }
  777.         else
  778.         {
  779.             if (e.frags > sort.frags)
  780.             {
  781.                 e.chain = sort;
  782.                 sort = e;
  783.             }
  784.             else
  785.             {
  786.                 walk = sort;
  787.                 do
  788.                 {
  789.                     if (!walk.chain)
  790.                     {
  791.                         e.chain = world;
  792.                         walk.chain = e;
  793.                     }
  794.                     else if (walk.chain.frags < e.frags)
  795.                     {
  796.                         e.chain = walk.chain;
  797.                         walk.chain = e;
  798.                     }
  799.                     else
  800.                         walk = walk.chain;
  801.                 } while (walk.chain != e);
  802.             }
  803.         }
  804.         
  805.         e = find(e, classname, "player");
  806.     }
  807.  
  808. // print the list
  809.     
  810.     bprint ("\n");    
  811.     while (sort)
  812.     {
  813.         PrintClientScore (sort);
  814.         sort = sort.chain;
  815.     }
  816.     bprint ("\n");
  817. };
  818.  
  819. /*
  820. go to the next level for deathmatch
  821. */
  822. void() NextLevel =
  823. {
  824.     local entity o;
  825.  
  826. // find a trigger changelevel
  827.     o = find(world, classname, "trigger_changelevel");
  828.     if (!o || mapname == "start")
  829.     {    // go back to same map if no trigger_changelevel
  830.         o = spawn();
  831.         o.map = mapname;
  832.     }
  833.  
  834.     nextmap = o.map;
  835.     
  836.     if (o.nextthink < time)
  837.     {
  838.         o.think = execute_changelevel;
  839.         o.nextthink = time + 0.1;
  840.     }
  841. };
  842.  
  843. /*
  844. ============
  845. CheckRules
  846.  
  847. Exit deathmatch games upon conditions
  848. ============
  849. */
  850. void() CheckRules =
  851. {
  852.     local    float        timelimit;
  853.     local    float        fraglimit;
  854.  
  855.     if (gameover)    // someone else quit the game already
  856.         return;
  857.  
  858.     timelimit = cvar("timelimit") * 60;
  859.     fraglimit = cvar("fraglimit");
  860.  
  861.     if (timelimit && time >= timelimit)
  862.     {
  863. NextLevel ();
  864. /*
  865.         gameover = TRUE;
  866.         bprint ("\n\n\n==============================\n");
  867.         bprint ("game exited after ");
  868.         bprint (ftos(timelimit/60));
  869.         bprint (" minutes\n");
  870.         DumpScore ();
  871.         localcmd ("killserver\n");
  872. */
  873.         return;
  874.     }
  875.     
  876.     if (fraglimit && self.frags >= fraglimit)
  877.     {
  878. NextLevel ();
  879. /*
  880.         gameover = TRUE;
  881.         bprint ("\n\n\n==============================\n");
  882.         bprint ("game exited after ");
  883.         bprint (ftos(self.frags));
  884.         bprint (" frags\n");
  885.         DumpScore ();
  886.         localcmd ("killserver\n");
  887. */
  888.         return;
  889.     }    
  890. };
  891.  
  892. //============================================================================
  893.  
  894. void() PlayerDeathThink =
  895. {
  896.     local float        forward;
  897.  
  898.     if ((self.flags & FL_ONGROUND))
  899.     {
  900.         forward = vlen (self.velocity);
  901.         forward = forward - 20;
  902.         if (forward <= 0)
  903.             self.velocity = '0 0 0';
  904.         else    
  905.             self.velocity = forward * normalize(self.velocity);
  906.     }
  907.  
  908. // wait for all buttons released
  909.     if (self.deadflag == DEAD_DEAD)
  910.     {
  911.         if (self.button2 || self.button1 || self.button0)
  912.             return;
  913.         self.deadflag = DEAD_RESPAWNABLE;
  914.         button_pressed = 0;
  915.         return;
  916.     }
  917.  
  918.     // Wait for any button to be pressed and released.
  919.     if (!button_pressed)
  920.     {
  921.         if (self.button2 || self.button1 || self.button0)
  922.             button_pressed = 1;
  923.         return;
  924.     }
  925.     else
  926.     {
  927.         if (self.button2 || self.button1 || self.button0)
  928.             return;
  929.     }
  930.  
  931.     // DD code
  932.     if (teamplay < 0 && self.team == actual_team2)
  933.     {
  934.         sprint(self, "You're still IT!\n");
  935.         IT_time = time;
  936.     }
  937.     respawn();
  938. };
  939.  
  940.  
  941. void() PlayerJump =
  942. {
  943.     local vector start, end;
  944.     
  945.     if (self.flags & FL_WATERJUMP)
  946.         return;
  947.  
  948.     if (self.waterlevel >= 2)
  949.     {
  950.         if (self.watertype == CONTENT_WATER)
  951.             self.velocity_z = 100;
  952.         else if (self.watertype == CONTENT_SLIME)
  953.             self.velocity_z = 80;
  954.         else
  955.             self.velocity_z = 50;
  956.  
  957. // play swiming sound
  958.         if (self.swim_flag < time)
  959.         {
  960.             self.swim_flag = time + 1;
  961.             if (random() < 0.5)
  962.                 sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM);
  963.             else
  964.                 sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM);
  965.         }
  966.  
  967.         return;
  968.     }
  969.  
  970.     if ( !(self.flags & FL_ONGROUND) && self.velocity_z )
  971.         return;
  972.  
  973.     if ( !(self.flags & FL_JUMPRELEASED) )
  974.         return;        // don't pogo stick
  975.  
  976.     self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  977.  
  978.     self.flags = self.flags - FL_ONGROUND;    // don't stairwalk
  979.     
  980.     self.button2 = 0;
  981. // player jumping sound
  982.     sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
  983.     self.velocity_z = self.velocity_z + 270;
  984. };
  985.  
  986.  
  987. /*
  988. ===========
  989. WaterMove
  990.  
  991. ============
  992. */
  993. .float    dmgtime;
  994.  
  995. void() WaterMove =
  996. {
  997.     if (self.movetype == MOVETYPE_NOCLIP)
  998.         return;
  999.     if (self.health < 0)
  1000.         return;
  1001.  
  1002.     if (self.waterlevel != 3)
  1003.     {
  1004.         if (self.air_finished < time)
  1005.             sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM);
  1006.         else if (self.air_finished < time + 9)
  1007.             sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM);
  1008.         self.air_finished = time + 12;
  1009.         self.dmg = 2;
  1010.     }
  1011.     else if (self.air_finished < time)
  1012.     {    // drown!
  1013.         if (self.pain_finished < time)
  1014.         {
  1015.             self.dmg = self.dmg + 2;
  1016.             if (self.dmg > 15)
  1017.                 self.dmg = 10;
  1018.             T_Damage (self, world, world, self.dmg);
  1019.             self.pain_finished = time + 1;
  1020.         }
  1021.     }
  1022.     
  1023.     if (!self.waterlevel)
  1024.     {
  1025.         if (self.flags & FL_INWATER)
  1026.         {    
  1027.             // play leave water sound
  1028.             sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM);
  1029.             self.flags = self.flags - FL_INWATER;
  1030.         }
  1031.         return;
  1032.     }
  1033.  
  1034.     if (self.watertype == CONTENT_LAVA)
  1035.     {    // do damage
  1036.         if (self.dmgtime < time)
  1037.         {
  1038.             if (self.radsuit_finished > time)
  1039.                 self.dmgtime = time + 1;
  1040.             else
  1041.                 self.dmgtime = time + 0.2;
  1042.  
  1043.             T_Damage (self, world, world, 10*self.waterlevel);
  1044.         }
  1045.     }
  1046.     else if (self.watertype == CONTENT_SLIME)
  1047.     {    // do damage
  1048.         if (self.dmgtime < time && self.radsuit_finished < time)
  1049.         {
  1050.             self.dmgtime = time + 1;
  1051.             T_Damage (self, world, world, 4*self.waterlevel);
  1052.         }
  1053.     }
  1054.     
  1055.     if ( !(self.flags & FL_INWATER) )
  1056.     {    
  1057.  
  1058. // player enter water sound
  1059.  
  1060.         if (self.watertype == CONTENT_LAVA)
  1061.             sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM);
  1062.         if (self.watertype == CONTENT_WATER)
  1063.             sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM);
  1064.         if (self.watertype == CONTENT_SLIME)
  1065.             sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM);
  1066.  
  1067.         self.flags = self.flags + FL_INWATER;
  1068.         self.dmgtime = 0;
  1069.     }
  1070.     
  1071.     if (! (self.flags & FL_WATERJUMP) )
  1072.         self.velocity = self.velocity - 0.8*self.waterlevel*frametime*self.velocity;
  1073. };
  1074.  
  1075. void() CheckWaterJump =
  1076. {
  1077.     local vector start, end;
  1078.  
  1079. // check for a jump-out-of-water
  1080.     makevectors (self.angles);
  1081.     start = self.origin;
  1082.     start_z = start_z + 8; 
  1083.     v_forward_z = 0;
  1084.     normalize(v_forward);
  1085.     end = start + v_forward*24;
  1086.     traceline (start, end, TRUE, self);
  1087.     if (trace_fraction < 1)
  1088.     {    // solid at waist
  1089.         start_z = start_z + self.maxs_z - 8;
  1090.         end = start + v_forward*24;
  1091.         self.movedir = trace_plane_normal * -50;
  1092.         traceline (start, end, TRUE, self);
  1093.         if (trace_fraction == 1)
  1094.         {    // open at eye level
  1095.             self.flags = self.flags | FL_WATERJUMP;
  1096.             self.velocity_z = 225;
  1097.             self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  1098.             self.teleport_time = time + 2;    // safety net
  1099.             return;
  1100.         }
  1101.     }
  1102. };
  1103.  
  1104.  
  1105. /*
  1106. ================
  1107. PlayerPreThink
  1108.  
  1109. Called every frame before physics are run
  1110. ================
  1111. */
  1112. void() PlayerPreThink =
  1113. {
  1114.     if (intermission_running)
  1115.     {
  1116.         IntermissionThink ();    // otherwise a button could be missed between
  1117.         return;                    // the think tics
  1118.     }
  1119.  
  1120.     if (self.view_ofs == '0 0 0')
  1121.         return;        // intermission or finale
  1122.  
  1123.     makevectors (self.v_angle);        // is this still used
  1124.  
  1125.     CheckRules ();
  1126.     WaterMove ();
  1127.  
  1128.     // DD code - 
  1129.     // Assign new player to a team and
  1130.     // don't allow a player to change teams!
  1131.     if (self.check_team_time && time >= self.check_team_time)
  1132.     {
  1133.         if (self.start_team == 0)  // New player?
  1134.             self.impulse = 202;
  1135.         else if (self.team != self.start_team)  // Attempt to change sides?
  1136.             self.impulse = 202;
  1137.         else if (teamplay < 0)  // Game of tag?
  1138.         {
  1139.             if (self.start_team == actual_team2  // Is player IT and alive?
  1140.                     && !self.deadflag)
  1141.             {
  1142.                 if (time == IT_time + 30)
  1143.                 {
  1144.                     sprint(self, "You're still IT!");
  1145.                     IT_time = IT_time - 0.1;
  1146.                 }
  1147.                 if (!IT_time)
  1148.                     IT_time = time;
  1149.                 else if (time >= IT_time + 60)  // Has a minute as IT passed?
  1150.                 {
  1151.                     bprint(self.netname);
  1152.                     bprint(" earned a bonus survival frag.\n");
  1153.                     self.frags = self.frags + 1;
  1154.                     IT_time = time;
  1155.                 }
  1156.             }
  1157.         }
  1158.     }
  1159.         
  1160.     if (self.waterlevel == 2)
  1161.         CheckWaterJump ();
  1162.  
  1163.     if (self.deadflag >= DEAD_DEAD)
  1164.     {
  1165.         PlayerDeathThink ();
  1166.         return;
  1167.     }
  1168.     
  1169.     if (self.deadflag == DEAD_DYING)
  1170.         return;    // dying, so do nothing
  1171.  
  1172.     if (self.button2)
  1173.     {
  1174.         PlayerJump ();
  1175.     }
  1176.     else
  1177.         self.flags = self.flags | FL_JUMPRELEASED;
  1178.  
  1179. // teleporters can force a non-moving pause time    
  1180.     if (time < self.pausetime)
  1181.         self.velocity = '0 0 0';
  1182. };
  1183.     
  1184. /*
  1185. ================
  1186. CheckPowerups
  1187.  
  1188. Check for turning off powerups
  1189. ================
  1190. */
  1191. void() CheckPowerups =
  1192. {
  1193.     if (self.health <= 0)
  1194.         return;
  1195.  
  1196. // invisibility
  1197.     if (self.invisible_finished)
  1198.     {
  1199. // sound and screen flash when items starts to run out
  1200.         if (self.invisible_sound < time)
  1201.         {
  1202.             sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE);
  1203.             self.invisible_sound = time + ((random() * 3) + 1);
  1204.         }
  1205.  
  1206.  
  1207.         if (self.invisible_finished < time + 3)
  1208.         {
  1209.             if (self.invisible_time == 1)
  1210.             {
  1211.                 sprint (self, "Ring of Shadows magic is fading\n");
  1212.                 stuffcmd (self, "bf\n");
  1213.                 sound (self, CHAN_AUTO, "items/inv2.wav", 1, ATTN_NORM);
  1214.                 self.invisible_time = time + 1;
  1215.             }
  1216.             
  1217.             if (self.invisible_time < time)
  1218.             {
  1219.                 self.invisible_time = time + 1;
  1220.                 stuffcmd (self, "bf\n");
  1221.             }
  1222.         }
  1223.  
  1224.         if (self.invisible_finished < time)
  1225.         {    // just stopped
  1226.             self.items = self.items - IT_INVISIBILITY;
  1227.             self.invisible_finished = 0;
  1228.             self.invisible_time = 0;
  1229.         }
  1230.         
  1231.     // use the eyes
  1232.         self.frame = 0;
  1233.         self.modelindex = modelindex_eyes;
  1234.     }
  1235.     else
  1236.         self.modelindex = modelindex_player;    // don't use eyes
  1237.  
  1238. // invincibility
  1239.     if (self.invincible_finished)
  1240.     {
  1241. // sound and screen flash when items starts to run out
  1242.         if (self.invincible_finished < time + 3)
  1243.         {
  1244.             if (self.invincible_time == 1)
  1245.             {
  1246.                 sprint (self, "Protection is almost burned out\n");
  1247.                 stuffcmd (self, "bf\n");
  1248.                 sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM);
  1249.                 self.invincible_time = time + 1;
  1250.             }
  1251.             
  1252.             if (self.invincible_time < time)
  1253.             {
  1254.                 self.invincible_time = time + 1;
  1255.                 stuffcmd (self, "bf\n");
  1256.             }
  1257.         }
  1258.         
  1259.         if (self.invincible_finished < time)
  1260.         {    // just stopped
  1261.             self.items = self.items - IT_INVULNERABILITY;
  1262.             self.invincible_time = 0;
  1263.             self.invincible_finished = 0;
  1264.         }
  1265.         if (self.invincible_finished > time)
  1266.             self.effects = self.effects | EF_DIMLIGHT;
  1267.         else
  1268.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1269.     }
  1270.  
  1271. // super damage
  1272.     if (self.super_damage_finished)
  1273.     {
  1274.  
  1275. // sound and screen flash when items starts to run out
  1276.  
  1277.         if (self.super_damage_finished < time + 3)
  1278.         {
  1279.             if (self.super_time == 1)
  1280.             {
  1281.                 sprint (self, "Quad Damage is wearing off\n");
  1282.                 stuffcmd (self, "bf\n");
  1283.                 sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
  1284.                 self.super_time = time + 1;
  1285.             }      
  1286.             
  1287.             if (self.super_time < time)
  1288.             {
  1289.                 self.super_time = time + 1;
  1290.                 stuffcmd (self, "bf\n");
  1291.             }
  1292.         }
  1293.  
  1294.         if (self.super_damage_finished < time)
  1295.         {    // just stopped
  1296.             self.items = self.items - IT_QUAD;
  1297.             self.super_damage_finished = 0;
  1298.             self.super_time = 0;
  1299.         }
  1300.         if (self.super_damage_finished > time)
  1301.             self.effects = self.effects | EF_DIMLIGHT;
  1302.         else
  1303.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1304.     }    
  1305.  
  1306. // suit    
  1307.     if (self.radsuit_finished)
  1308.     {
  1309.         self.air_finished = time + 12;        // don't drown
  1310.  
  1311. // sound and screen flash when items starts to run out
  1312.         if (self.radsuit_finished < time + 3)
  1313.         {
  1314.             if (self.rad_time == 1)
  1315.             {
  1316.                 sprint (self, "Air supply in Biosuit expiring\n");
  1317.                 stuffcmd (self, "bf\n");
  1318.                 sound (self, CHAN_AUTO, "items/suit2.wav", 1, ATTN_NORM);
  1319.                 self.rad_time = time + 1;
  1320.             }
  1321.             
  1322.             if (self.rad_time < time)
  1323.             {
  1324.                 self.rad_time = time + 1;
  1325.                 stuffcmd (self, "bf\n");
  1326.             }
  1327.         }
  1328.  
  1329.         if (self.radsuit_finished < time)
  1330.         {    // just stopped
  1331.             self.items = self.items - IT_SUIT;
  1332.             self.rad_time = 0;
  1333.             self.radsuit_finished = 0;
  1334.         }
  1335.     }    
  1336. };
  1337.  
  1338.  
  1339. /*
  1340. ================
  1341. PlayerPostThink
  1342.  
  1343. Called every frame after physics are run
  1344. ================
  1345. */
  1346. void() PlayerPostThink =
  1347. {
  1348.     if (self.view_ofs == '0 0 0')
  1349.         return;        // intermission or finale
  1350.     if (self.deadflag)
  1351.         return;
  1352.  
  1353. // do weapon stuff
  1354.  
  1355.     W_WeaponFrame ();
  1356.  
  1357. // check to see if player landed and play landing sound    
  1358.     if (self.flags & FL_ONGROUND)
  1359.     {
  1360.         if (self.jump_flag < -300 && self.health > 0)
  1361.         {
  1362.             if (self.watertype == CONTENT_WATER)
  1363.                 sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
  1364.             else if (self.jump_flag < -650)
  1365.             {
  1366.                 T_Damage (self, world, world, 5); 
  1367.                 sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  1368.                 self.deathtype = "falling";
  1369.             }
  1370.             else
  1371.                 sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
  1372.         }
  1373.         self.jump_flag = 0;
  1374.     }
  1375.     else
  1376.         self.jump_flag = self.velocity_z;
  1377.  
  1378.     CheckPowerups ();
  1379. };
  1380.  
  1381.  
  1382. /*
  1383. ===========
  1384. ClientConnect
  1385.  
  1386. called when a player connects to a server
  1387. ============
  1388. */
  1389. void() ClientConnect =
  1390. {
  1391.     // DD code
  1392.     connect_player = self;
  1393.  
  1394.     bprint (self.netname);
  1395.     bprint (" entered the game\n");
  1396.  
  1397. // a client connecting during an intermission can cause problems
  1398.     if (intermission_running)
  1399.         ExitIntermission ();
  1400. };
  1401.  
  1402.  
  1403. /*
  1404. ===========
  1405. ClientDisconnect
  1406.  
  1407. called when a player disconnects from a server
  1408. ============
  1409. */
  1410. void() ClientDisconnect =
  1411. {
  1412.     if (gameover)
  1413.         return;
  1414.     // if the level end trigger has been activated, just return
  1415.     // since they aren't *really* leaving
  1416.  
  1417.     // let everyone else know
  1418.     bprint (self.netname);
  1419.     bprint (" left the game with ");
  1420.     bprint (ftos(self.frags));
  1421.     bprint (" frags\n");
  1422.     sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
  1423.     set_suicide_frame ();
  1424.  
  1425.     // DD code
  1426.     if (teamplay < 0)
  1427.     {
  1428.         local float team1;
  1429.         local float team2;
  1430.         local entity first;
  1431.         local entity it;
  1432.  
  1433.         // Tag a new player IT only if there are two or more players remaining.
  1434.         team1 = 0;
  1435.         team2 = 0;
  1436.         other = find (world, classname, "player");
  1437.         while (other != world)
  1438.         {
  1439.             if (other != self)
  1440.             {
  1441.                 if (other.start_team == actual_team1)
  1442.                 {
  1443.                     if (team1 == 0)
  1444.                         first = other;
  1445.                     team1 = team1 + 1;
  1446.                 }
  1447.                 else  // IT!
  1448.                 {
  1449.                     it = other;
  1450.                     team2 = team2 + 1;
  1451.                 }
  1452.             }
  1453.             other = find (other, classname, "player");
  1454.         }
  1455.         if (self.start_team == actual_team2)  // Was exiting player IT?
  1456.         {
  1457.             // Make certain there are still two or more players.
  1458.             if (team1 > 1)
  1459.             {
  1460.                 ConfigTeam(2, 0);
  1461.                 first.start_team = assigned_team;
  1462.                 first.team = -1;  // Indicate a tag was made.
  1463.             }
  1464.         }
  1465.         else if (team1 == 0 && team2)  // Remove IT if no more players hunting.
  1466.         {
  1467.             ConfigTeam(1, 0);
  1468.             it.start_team = assigned_team;
  1469.             it.team = -1;  // Indicate a tag was made.
  1470.  
  1471.             sprint(it, "You're no longer IT as there are no players left to tag you.\n");
  1472.         }
  1473.     }
  1474. };
  1475.  
  1476. /*
  1477. ===========
  1478. ClientObituary
  1479.  
  1480. called when a player dies
  1481. ============
  1482. */
  1483. void(entity targ, entity attacker) ClientObituary =
  1484. {
  1485.     local    float rnum;
  1486.     local    string deathstring, deathstring2;
  1487.     rnum = random();
  1488.  
  1489.     if (targ.classname == "player")
  1490.     {
  1491.         local float targ_value;
  1492.         targ_value = 1;
  1493.         if (teamplay < 0)  // Game of tag?
  1494.         {
  1495.             if (targ.start_team == actual_team2)  // Was target IT?
  1496.                 targ_value = 3;
  1497.         }
  1498.         if (attacker.classname == "teledeath")
  1499.         {
  1500.             bprint (targ.netname);
  1501.             bprint (" was telefragged by ");
  1502.             bprint (attacker.owner.netname);
  1503.             bprint ("\n");
  1504.  
  1505.             // DD - Don't reward a player for telefragging a teammate.
  1506.             if (teamplay <= 0 || attacker.start_team != targ.start_team)
  1507.                 attacker.owner.frags = attacker.owner.frags + targ_value;
  1508.             return;
  1509.         }
  1510.  
  1511.         if (attacker.classname == "teledeath2")
  1512.         {
  1513.             bprint ("Satan's power deflects ");
  1514.             bprint (targ.netname);
  1515.             bprint ("'s telefrag\n");
  1516.  
  1517.             targ.frags = targ.frags - 1;
  1518.             return;
  1519.         }
  1520.  
  1521.         if (attacker.classname == "player")
  1522.         {
  1523.             if (targ == attacker)
  1524.             {
  1525.                 // killed self
  1526.                 attacker.frags = attacker.frags - 1;
  1527.                 bprint (targ.netname);
  1528.                 
  1529.                 if (targ.weapon == 64 && targ.waterlevel > 1)
  1530.                 {
  1531.                     bprint (" discharges into the water.\n");
  1532.                     return;
  1533.                 }
  1534.                 if (targ.weapon == 16)
  1535.                     bprint (" tries to put the pin back in\n");
  1536.                 else if (rnum < 0.5)
  1537.                     bprint (" becomes bored with life\n");
  1538.                 else
  1539.                     bprint (" checks if his weapon is loaded\n");
  1540.                 return;
  1541.             }
  1542.             else
  1543.             {
  1544.                 attacker.frags = attacker.frags + targ_value;
  1545.  
  1546.                 rnum = attacker.weapon;
  1547.                 if (rnum == IT_AXE)
  1548.                 {
  1549.                     deathstring = " was ax-murdered by ";
  1550.                     deathstring2 = "\n";
  1551.                 }
  1552.         if (rnum == IT_MORNINGSTAR)
  1553.         {
  1554.           deathstring = " was hooked by ";
  1555.           deathstring2 = "\n";
  1556.         }
  1557.                 if (rnum == IT_SHOTGUN)
  1558.                 {
  1559.                     deathstring = " chewed on ";
  1560.                     deathstring2 = "'s boomstick\n";
  1561.                 }
  1562.                 if (rnum == IT_SUPER_SHOTGUN)
  1563.                 {
  1564.                     deathstring = " ate 2 loads of ";
  1565.                     deathstring2 = "'s buckshot\n";
  1566.                 }
  1567.                 if (rnum == IT_NAILGUN)
  1568.                 {
  1569.                     deathstring = " was nailed by ";
  1570.                     deathstring2 = "\n";
  1571.                 }
  1572.                 if (rnum == IT_SUPER_NAILGUN)
  1573.                 {
  1574.                     deathstring = " was punctured by ";
  1575.                     deathstring2 = "\n";
  1576.                 }
  1577.                 if (rnum == IT_GRENADE_LAUNCHER)
  1578.                 {
  1579.                     if (targ.health < -40)
  1580.                     {
  1581.                         deathstring = " was gibbed by ";
  1582.                         deathstring2 = "'s grenade\n";
  1583.                     }
  1584.                     else
  1585.                     {
  1586.                         deathstring = " eats ";
  1587.                         deathstring2 = "'s pineapple\n";
  1588.                     }
  1589.                 }
  1590.         if (rnum == IT_FLAMETHROWER)
  1591.                 {
  1592.           deathstring = " is invited to ";
  1593.           deathstring2 = "'s barbeque\n";
  1594.                 }
  1595.                 if (rnum == IT_ROCKET_LAUNCHER)
  1596.                 {
  1597.                     if (targ.health < -40)
  1598.                     {
  1599.                         deathstring = " was gibbed by ";
  1600.                         deathstring2 = "'s rocket\n" ;
  1601.                     }
  1602.                     else
  1603.                     {
  1604.                         deathstring = " rides ";
  1605.                         deathstring2 = "'s rocket\n";
  1606.                     }
  1607.                 }
  1608.                 if (rnum == IT_LIGHTNING)
  1609.                 {
  1610.                     deathstring = " accepts ";
  1611.                     if (attacker.waterlevel > 1)
  1612.                         deathstring2 = "'s discharge\n";
  1613.                     else
  1614.                         deathstring2 = "'s shaft\n";
  1615.                 }
  1616.                 bprint (targ.netname);
  1617.                 bprint (deathstring);
  1618.                 bprint (attacker.netname);
  1619.                 bprint (deathstring2);
  1620.  
  1621.                 // DD code
  1622.                 if (teamplay < 0)
  1623.                 {
  1624.                     // Remove IT from killed player.
  1625.                     ConfigTeam(1, 0);
  1626.                     targ.start_team = assigned_team;
  1627.                     targ.team = -1;  // Indicate a tag was made.
  1628.                     // Assign IT to killer.
  1629.                     ConfigTeam(2, 0);
  1630.                     attacker.start_team = assigned_team;
  1631.                     attacker.team = -1;  // Indicate a tag was made.
  1632.                 }
  1633.             }
  1634.             return;
  1635.         }
  1636.         else
  1637.         {
  1638.             targ.frags = targ.frags - 1;        // killed self
  1639.             rnum = targ.watertype;
  1640.  
  1641.             bprint (targ.netname);
  1642.             if (rnum == -3)
  1643.             {
  1644.                 if (random() < 0.5)
  1645.                     bprint (" sleeps with the fishes\n");
  1646.                 else
  1647.                     bprint (" sucks it down\n");
  1648.                 return;
  1649.             }
  1650.             else if (rnum == -4)
  1651.             {
  1652.                 if (random() < 0.5)
  1653.                     bprint (" gulped a load of slime\n");
  1654.                 else
  1655.                     bprint (" can't exist on slime alone\n");
  1656.                 return;
  1657.             }
  1658.             else if (rnum == -5)
  1659.             {
  1660.                 if (targ.health < -15)
  1661.                 {
  1662.                     bprint (" burst into flames\n");
  1663.                     return;
  1664.                 }
  1665.                 if (random() < 0.5)
  1666.                     bprint (" turned into hot slag\n");
  1667.                 else
  1668.                     bprint (" visits the Volcano God\n");
  1669.                 return;
  1670.             }
  1671.  
  1672.             if (attacker.flags & FL_MONSTER)
  1673.             {
  1674.                 if (attacker.classname == "monster_army")
  1675.                     bprint (" was shot by a Grunt\n");
  1676.                 if (attacker.classname == "monster_demon1")
  1677.                     bprint (" was eviscerated by a Fiend\n");
  1678.                 if (attacker.classname == "monster_dog")
  1679.                     bprint (" was mauled by a Rottweiler\n");
  1680.                 if (attacker.classname == "monster_dragon")
  1681.                     bprint (" was fried by a Dragon\n");
  1682.                 if (attacker.classname == "monster_enforcer")
  1683.                     bprint (" was blasted by an Enforcer\n");
  1684.                 if (attacker.classname == "monster_fish")
  1685.                     bprint (" was fed to the Rotfish\n");
  1686.                 if (attacker.classname == "monster_hell_knight")
  1687.                     bprint (" was slain by a Death Knight\n");
  1688.                 if (attacker.classname == "monster_knight")
  1689.                     bprint (" was slashed by a Knight\n");
  1690.                 if (attacker.classname == "monster_ogre")
  1691.                     bprint (" was destroyed by an Ogre\n");
  1692.                 if (attacker.classname == "monster_oldone")
  1693.                     bprint (" became one with Shub-Niggurath\n");
  1694.                 if (attacker.classname == "monster_shalrath")
  1695.                     bprint (" was exploded by a Vore\n");
  1696.                 if (attacker.classname == "monster_shambler")
  1697.                     bprint (" was smashed by a Shambler\n");
  1698.                 if (attacker.classname == "monster_tarbaby")
  1699.                     bprint (" was slimed by a Spawn\n");
  1700.                 if (attacker.classname == "monster_vomit")
  1701.                     bprint (" was vomited on by a Vomitus\n");
  1702.                 if (attacker.classname == "monster_wizard")
  1703.                     bprint (" was scragged by a Scrag\n");
  1704.                 if (attacker.classname == "monster_zombie")
  1705.                     bprint (" joins the Zombies\n");
  1706.  
  1707.                 return;
  1708.             }
  1709.             if (attacker.classname == "explo_box")
  1710.             {
  1711.                 bprint (" blew up\n");
  1712.                 return;
  1713.             }
  1714.             if (attacker.solid == SOLID_BSP && attacker != world)
  1715.             {    
  1716.                 bprint (" was squished\n");
  1717.                 return;
  1718.             }
  1719.             if (targ.deathtype == "falling")
  1720.             {
  1721.                 targ.deathtype = "";
  1722.                 bprint (" fell to his death\n");
  1723.                 return;
  1724.             }
  1725.             if (attacker.classname == "trap_shooter" || attacker.classname == "trap_spikeshooter")
  1726.             {
  1727.                 bprint (" was spiked\n");
  1728.                 return;
  1729.             }
  1730.             if (attacker.classname == "fireball")
  1731.             {
  1732.                 bprint (" ate a lavaball\n");
  1733.                 return;
  1734.             }
  1735.             if (attacker.classname == "trigger_changelevel")
  1736.             {
  1737.                 bprint (" tried to leave\n");
  1738.                 return;
  1739.             }
  1740.  
  1741.             bprint (" died\n");
  1742.         }
  1743.     }
  1744. };
  1745.